<?php
defined('SECUR_CHECK') or die("Security error");
/*
 * grid.php
 *
 * Creates XML based on the sessions table, used by the grid
 */

/*
 * Manipulates the data which is send to the grid
 * i.e. turn timestamps to dates
 */
function data_manipulate($row)
{
    global $user;
    
    // Formatting date field
    $timestamp = $row->get_value('session_date');
    $row->set_value('session_date', date($user->get_option('brm_user_dateformat'), $timestamp));

    // Strip <p> tags from notes
    $notes = $row->get_value('session_notes');
    $row->set_value('session_notes', strip_tags($notes));
}
require_once(ABSPATH."/includes/dhtmlxconnector/grid_connector.php");
$grid = new GridConnector($database->handler);
//$grid->render_table("brm_menu", "id", "id, menu_name");
$grid->event->attach("beforeRender","data_manipulate");
$grid->render_sql("SELECT id, session_date, session_location, session_type, session_game, session_hours, session_result, session_notes  FROM brm_sessions WHERE session_user_id = '{$user->id}'", "id", "session_date, session_location, session_type, session_game, session_hours, session_result, session_notes");
exit;
?>
